import 'package:flutter/material.dart';

class HorizontalList extends StatelessWidget {
  final List<Map<String, Object>> items;

  const HorizontalList({ super.key, required this.items });

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 150,
      child: PageView.builder(
        // scrollDirection: Axis.horizontal,
        pageSnapping: true,
        itemCount: items.length,
        controller: PageController(viewportFraction: 0.95),
        itemBuilder: (context, index) {
          final Map<String, Object> person = items[index];
          return Container(
            width: 200.0,
            margin: const EdgeInsets.symmetric(horizontal: 4.0),
            decoration: BoxDecoration(
              color: Colors.orange,
              borderRadius: BorderRadius.circular(10),
              border: Border.all(color: Colors.black45, width: 1.0)
            ),
            child: Padding(
              padding: const EdgeInsets.all(10.0),
              child: Column(
                children: <Widget>[
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(
                       '姓名： ${person['name']}',
                        style: const TextStyle(color: Colors.white)
                      ),
                      Text(
                        '年龄： ${person['age']}',
                         style: const TextStyle(color: Colors.white)
                      )
                    ],
                  ),
                  const SizedBox(
                    height: 10,
                  ),
                  Row(
                    children: <Widget>[
                      Text(
                        '工作： ${person['work']}',
                         style: const TextStyle(color: Colors.white)
                      ),
                    ],
                  ),
                ],
              ),
            ),

          );
        },
      ),
    );
  }
}